Skip to content

feat: add stats/base/dists/anglit/stdev#11489

Merged
Planeshifter merged 3 commits into
stdlib-js:developfrom
Om-A-osc:feat/stats-base-dists-anglit-stdev
Jul 5, 2026
Merged

feat: add stats/base/dists/anglit/stdev#11489
Planeshifter merged 3 commits into
stdlib-js:developfrom
Om-A-osc:feat/stats-base-dists-anglit-stdev

Conversation

@Om-A-osc

Copy link
Copy Markdown
Contributor

type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:

  • task: lint_filenames status: passed
  • task: lint_editorconfig status: passed
  • task: lint_markdown status: passed
  • task: lint_package_json status: passed
  • task: lint_repl_help status: passed
  • task: lint_javascript_src status: passed
  • task: lint_javascript_cli status: na
  • task: lint_javascript_examples status: passed
  • task: lint_javascript_tests status: passed
  • task: lint_javascript_benchmarks status: passed
  • task: lint_python status: passed
  • task: lint_r status: na
  • task: lint_c_src status: passed
  • task: lint_c_examples status: passed
  • task: lint_c_benchmarks status: passed
  • task: lint_c_tests_fixtures status: na
  • task: lint_shell status: na
  • task: lint_typescript_declarations status: passed
  • task: lint_typescript_tests status: passed
  • task: lint_license_headers status: passed

Progresses #9960.

Description

What is the purpose of this pull request?

This pull request:

  • adds stats/base/dists/anglit/stdev
  • implements the standard deviation for the Anglit distribution
  • includes unit tests and documentation
  • follows stdlib conventions and project structure

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request?

Implementation follows existing distribution mode modules and adheres to stdlib coding standards.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation
  • Test/benchmark generation
  • Documentation
  • Research and understanding

Disclosure

N/A


@stdlib-js/reviewers

@Om-A-osc Om-A-osc requested a review from a team April 16, 2026 19:37
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. labels Apr 16, 2026
@stdlib-bot

stdlib-bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/anglit/stdev $\\color{green}180/180$
$\\color{green}+0.00\\%$
$\\color{green}9/9$
$\\color{green}+0.00\\%$
$\\color{green}2/2$
$\\color{green}+0.00\\%$
$\\color{green}180/180$
$\\color{green}+0.00\\%$

The above coverage report was generated for the changes in this PR.

@Neerajpathak07 Neerajpathak07 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Om-A-osc Thank you for working on this!!! Left out a few comments.

static double benchmark( void ) {
double elapsed;
double sigma[ 100 ];
double mu[ 100 ];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
double mu[ 100 ];
static double benchmark( void ) {
double sigma[ 100 ];
double mu[ 100 ];
double elapsed;

Ordering by length

// TypeScript Version: 4.1

/**
* Returns the standard deviation for an anglit distribution with location `mu` and scale `sigma`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Returns the standard deviation for an anglit distribution with location `mu` and scale `sigma`.
* Returns the standard deviation for an anglit distribution with location parameter `mu` and scale parameter `sigma`.

Feel free to update the description wherever relevant throughout the PR if you feel this makes more sense.

NaN

See Also
--------

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--------
--------


// VARIABLES //

// sqrt( (π²/16) - (1/2) ):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// sqrt( (π²/16) - (1/2) ):
// sqrt( (π²/16) - (1/2) )

#include "stdlib/stats/base/dists/anglit/stdev.h"
#include "stdlib/math/base/assert/is_nan.h"

static const double STDLIB_ANGLIT_STDEV_CONST = 0.3418336950449515; // sqrt( (π²/16) - (1/2) )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this const here would be acceptable as per discussed in the Office Hours conducted on April 14th.

Suggested change
static const double STDLIB_ANGLIT_STDEV_CONST = 0.3418336950449515; // sqrt( (π²/16) - (1/2) )
// sqrt( (π²/16) - (1/2) )
static const double STDEV_CONST = 0.3418336950449515;

Let's stay consist with the variable name as per used in the JS implementation. Also something which we closely follow for special math functions. Re:- powf

stdlib_base_is_nan( sigma ) ||
sigma <= 0.0
) {
return 0.0/0.0; // NaN

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 0.0/0.0; // NaN
return 0.0 / 0.0; // NaN


# Arguments

* `mean`: mean parameter (mu)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `mean`: mean parameter (mu)
* `mean`: location parameter (mu)

mu here is a location parameter not mean.

# Examples

``` python
python> mean = rand(1000) * 10.0 - 5.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment.

"""Generate fixture data."""
mean = rand(1000) * 10.0 - 5.0
scale = rand(1000) * 10.0 + 1.0
gen(mean, scale, "data.json")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to do a clean-up on this runner file.


The [standard deviation][stdev] for an [anglit][anglit-distribution] random variable with location parameter `mu` and scale parameter `sigma` is

<!-- <equation class="equation" label="eq:anglit_stdev" align="center" raw="\operatorname{SD}(X) = \sigma \sqrt{\left({\frac{\pi^{2}}{16}}-\frac{1}{2}\right)}" alt="Standard deviation for an anglit distribution."> -->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While previewing the markdown documentation the equation is not generated here properly. Mind fixing that as well.
Re:-

Image

@Neerajpathak07 Neerajpathak07 added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Apr 19, 2026
@Planeshifter Planeshifter force-pushed the feat/stats-base-dists-anglit-stdev branch from 9c85ee6 to 3b160f0 Compare July 5, 2026 05:39
Om-A-osc and others added 3 commits July 5, 2026 01:17
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: passed
  - task: lint_package_json
    status: passed
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: passed
  - task: lint_r
    status: na
  - task: lint_c_src
    status: passed
  - task: lint_c_examples
    status: passed
  - task: lint_c_benchmarks
    status: passed
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: passed
  - task: lint_license_headers
    status: passed
---
Apply reviewer feedback:

-   Rename the C constant to `STDEV_CONST` to match the JS variable name.
-   Reword the TSDoc summary to "location parameter `mu` and scale
    parameter `sigma`" across the JS, C, and TypeScript declarations.
-   Reorder the `benchmark/c/benchmark.c` local declarations by length.
-   Fix the `README.md` equation so it renders on GitHub by using
    `\mathop{\mathrm{SD}}` in the visible math block.
-   Clean up the Python fixture runner to name the location parameter
    `mu` (rather than `mean`) throughout.
-   Fix `See Also` divider spacing in the REPL help text.

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: passed
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: missing_dependencies
  - task: lint_r
    status: na
  - task: lint_c_src
    status: passed
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: passed
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: passed
  - task: lint_license_headers
    status: passed
---
The Python argument/variable name `mu` (2 chars) fails pylint's
invalid-name check (C0103), which requires >=3 characters. Rename the
identifier to `loc` while keeping the JSON output key `mu` unchanged,
as the test reads `data.mu`.

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: missing_dependencies
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@Planeshifter Planeshifter force-pushed the feat/stats-base-dists-anglit-stdev branch from 3b160f0 to 94db516 Compare July 5, 2026 06:17

@Planeshifter Planeshifter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's land! Thanks, @Om-A-osc!

@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Jul 5, 2026
@stdlib-bot stdlib-bot removed the Needs Changes Pull request which needs changes before being merged. label Jul 5, 2026
@stdlib-bot

stdlib-bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

PR Commit Message

feat: add `stats/base/dists/anglit/stdev`

PR-URL: https://github.com/stdlib-js/stdlib/pull/11489
Ref: https://github.com/stdlib-js/stdlib/issues/9960

Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com>
Reviewed-by: Neeraj Pathak <neerajrpathak710@gmail.com>
Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>

Please review the above commit message and make any necessary adjustments.

@Planeshifter Planeshifter dismissed Neerajpathak07’s stale review July 5, 2026 06:27

Feedback addressed.

@Planeshifter Planeshifter merged commit f2d8482 into stdlib-js:develop Jul 5, 2026
31 checks passed
@stdlib-bot stdlib-bot removed the Ready To Merge A pull request which is ready to be merged. label Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants